home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d21 / dvglue10.arc / TVFSWRIT.C < prev    next >
C/C++ Source or Header  |  1988-08-13  |  1KB  |  47 lines

  1. /*=======================================================*/
  2. /*  TVFSWRIT.C                                           */
  3. /*                                                       */
  4. /*  (c) Copyright 1988 Ralf Brown  All Rights Reserved   */
  5. /*  May be freely copied for noncommercial use, so long  */
  6. /*  as this copyright notice remains intact, and any     */
  7. /*  changes are marked in the comment blocks preceding   */
  8. /*  functions.                                           */
  9. /*=======================================================*/
  10.  
  11. #include <string.h>
  12. #include "tvapi.h"
  13. #include "tvstream.h"
  14.  
  15. /*=============================================*/
  16. /* TVfld_swrite  write string to field         */
  17. /*   Ralf Brown 4/5/88                         */
  18. /*=============================================*/
  19.  
  20. int pascal TVfld_swrite(OBJECT win,int field,char *s)
  21. {
  22.    char *dest ;
  23.    int size = TVqry_fieldsize(win,field) ;
  24.    BYTE *stream = (BYTE *)malloc(size+6) ;
  25.  
  26.    if (stream)
  27.       {
  28.       stream[0] = 0x1B ;
  29.       stream[1] = 0x00 ;
  30.       *((WORD *)(stream+2)) = size + 2 ;
  31.       stream[4] = 0xF3 ;
  32.       stream[5] = field ;
  33.       dest = (char *)stream+6 ;
  34.       while (*s && size--)
  35.          *dest++ = *s++ ;
  36.       while (size--)         /* pad rest of field with blanks */
  37.          *dest++ = ' ' ;
  38.       TVwin_stream(win,stream) ;
  39.       free(stream) ;
  40.       return TRUE ;
  41.       }
  42.    else
  43.       return FALSE ;
  44. }
  45.  
  46. /* End of TVFSWRIT.C */
  47.